<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

        

function Parent(name){
    this.name = name;
}
 
function Child(){
    //相当于把父类的this换成子类的实例
    Parent.call(this,"parent");
    this.age = 24;
}
let st1 = new Child('child');
let st2 = new Parent('gran')
console.log(st1);
console.log(st2);
    </script>
</body>
</html>